<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 第1步,引入vue文件,去https://cdn.bytedance.com/找 -->
    <script
      src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"
      type="application/javascript"
    ></script>
  </head>
  <body>
    <!-- 第2步创建根组件元素 -->
    <div id="app">
      <my-button @click="onClick">

      </my-button>
    </div>
  </body>
  <script>
    // 子组件向父组件发消息
    Vue.component('my-button',{
      template:`
      <div><button @click="$emit('click')">按钮</button></div>
      `
    })
    //第3步,创建vue的实例
    new Vue({
      el: "#app",
      methods:{
        onClick(){
          console.log(123);
        }
      }
    });
  </script>
</html>
